home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-03-16 | 1000 b | 52 lines | [TEXT/ttxt] |
- // Search for all objects with a specific string and replace
- // part of the name with a new one
- // (c) Christian Losch 1997
- // Maxon Computer GmbH
-
- DoIt(op,s1,s2)
- {
- var s3,pos;
- while (op)
- {
- s3 = op->GetName();
- pos = strstr(s3,s1);
-
- if (pos>=0)
- {
- var t1,t2,t3,len,ll;
- len = sizeof(s3);
- ll = sizeof(s1);
-
- if (pos>0) t1 = strmid(s3,0,pos-1); else t1="";
- t2 = s2;
- if (len-(pos+ll)>0) t3 = strmid(s3,pos+ll,len-(pos+ll)); else t3="";
-
- op->SetName(stradd(t1,t2,t3));
- }
- DoIt(op->GetDown(),s1,s2);
- op = op->GetNext();
- }
- }
-
-
-
- Function(doc)
- {
- var op,dlg = new (SimpleDialog);
-
-
- dlg->SetTitle("Find and Replace 2");
- dlg->SetData(0,"Find ",FIELD_STRING,0.0,0.0,"");
- dlg->SetData(1,"Replace",FIELD_STRING,0.0,0.0,"");
-
- if (!dlg->DoDialog()) return;
-
- DoIt(doc->GetFirstObject(),dlg->GetData(0),dlg->GetData(1));
-
- doc->SendMessage(DOCUMENT_CHANGED);
- }
-
- main()
- {
- RegisterMenuHook("Find and Replace 2","Function");
- }